import request, {
  Method,
  buyerUrl,
  commonUrl,
  managerUrl,
  sellerUrl,
  expertUrl
} from '@/plugins/request.js';

//课程目录
export function getCourseByCourseSeriesId(courseSeriesId) {
  return request({
    url: `${expertUrl}/expert/course/course/getCourseByCourseSeriesId/${courseSeriesId}`,
    method: Method.GET,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
  })
}

//课程目录->更新观看记录
export function updateWatchRecord(data) {
  return request({
    url: `${buyerUrl}/buyer/user/studyRecord/updateWatchRecord`,
    method: Method.POST,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}

//课程目录->观看目录->根据课程id获取观看详情
export function getObjByCourseId(id) {
  return request({
    url: `${expertUrl}/expert/course/course/${id}`,
    method: Method.GET,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
  })
}

//课程详情=》点击收藏
export function toCollect(data) {
  return request({
    url: `${buyerUrl}/buyer/passport/member/user/collect`,
    method: Method.POST,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}
//批量取消收藏
export function toCollectAll(data) {
  return request({
    url: `${buyerUrl}/buyer/passport/member/user/collect/delete`,
    method: Method.POST,
    needToken: true,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    data
  })
}

//课程详情=》点击关注
export function saveIdol(data) {
  return request({
    url: `${buyerUrl}/buyer/passport/member/user/saveIdol`,
    method: Method.POST,
    needToken: true,
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data
  })
}

//课程详情=》加入学习和立即购买
export function buyCourse(data) {
  return request({
    url: `${buyerUrl}/buyer/user/userCourse/userCourseOrder`,
    method: Method.POST,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
    data
  })
}

export function setCourseScId(id) {
  return request({
    url: `${expertUrl}/expert/course/courseSeries/courseSeriesLike/${id}`,
    method: Method.GET,
    needToken: true,
    headers: {
      'Content-Type': 'application/json'
    },
  })
}
